PROJECT(VIT)

INCLUDE(${CMAKE_ROOT}/Modules/FindVTK.cmake)
IF(VTK_FOUND)
  INCLUDE("${VTK_USE_FILE}")
  INCLUDE_DIRECTORIES(${VIT_SOURCE_DIR})

  SET(CMAKE_SKIP_RPATH 1)
  SET(VIT_FORWARD_DIR_BUILD ${VIT_BINARY_DIR})
  IF(CMAKE_CONFIGURATION_TYPES)
    SET(VIT_FORWARD_CONFIG_PRE "CMAKE_INTDIR \"/\" ")
    IF(VTK_CONFIGURATION_TYPES)
      SET(VIT_FORWARD_CONFIG_POST " \"/\" CMAKE_INTDIR")
    ENDIF()
  ENDIF()
  SET(VIT_PATH_BUILD_COMMA)
  FOREACH(dir ${VTK_RUNTIME_DIRS})
    SET(VIT_PATH_BUILD "${VIT_PATH_BUILD_COMMA} \"${dir}\"${VIT_FORWARD_CONFIG_POST}")
    SET(VIT_PATH_BUILD_COMMA ",")
  ENDFOREACH()
  SET(VIT_EXE_SUFFIX -real)
  SET(VIT_FORWARD_EXE_BUILD "${VIT_FORWARD_CONFIG_PRE}\"vit${VIT_EXE_SUFFIX}\"")
  SET(VIT_FORWARD_EXE_INSTALL "\"vit${VIT_EXE_SUFFIX}\"")
  CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/vit-forward.c.in
    ${CMAKE_CURRENT_BINARY_DIR}/vit-forward.c
    @ONLY)
  ADD_EXECUTABLE(vit
    ${CMAKE_CURRENT_BINARY_DIR}/vit-forward.c)
  INSTALL(TARGETS vit DESTINATION bin)

  ADD_EXECUTABLE(vit${VIT_EXE_SUFFIX} vit.cxx)
  TARGET_LINK_LIBRARIES(vit${VIT_EXE_SUFFIX} vtkGraphics)
  INSTALL(TARGETS vit${VIT_EXE_SUFFIX} DESTINATION bin)
ELSE()
  MESSAGE(SEND_ERROR "VTK not found!")
ENDIF()
